package com.job;

import com.netty.MyClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class ScheduledWork {


    @Scheduled(fixedDelay = 1000 * 30, initialDelay = 5000)
    public void checkChannel() {

        try {
            if (MyClient.mychannel != null && !MyClient.mychannel.isActive()) {
                log.info("开启重连.........");
                MyClient.reconnect();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
